package com.mdtx.database.convert;

import java.util.HashMap;
import java.util.Map;

/**
 * mysql和Java类型转换
 *
 * @author 猫啊
 * @create 2017-09-06 23:28
 **/
public class MysqlConvertToJavaMapping extends JavaMapping{

    private static final String MYSQL_TINYINT = "tinyint";
    private static final String MYSQL_SMALLINT = "smallint";
    private static final String MYSQL_MEDIUMINT = "mediumin";
    private static final String MYSQL_INT = "int";
    private static final String MYSQL_BIGINT = "bigint";
    private static final String MYSQL_FLOAT = "float";
    private static final String MYSQL_DOUBLE = "double";
    private static final String MYSQL_DECIMAL = "decimal";
    private static final String MYSQL_DATE = "date";
    private static final String MYSQL_TIME = "time";
    private static final String MYSQL_YEAR = "year";
    private static final String MYSQL_DATETIME = "datetime";
    private static final String MYSQL_TIMESTAMP = "timestamp";
    private static final String MYSQL_CHAR = "char";
    private static final String MYSQL_VARCHAR = "varchar";
    private static final String MYSQL_TINYBLOB = "tinyblob";
    private static final String MYSQL_TINYTEXT = "tinytext";
    private static final String MYSQL_BLOB = "blob";
    private static final String MYSQL_TEXT = "text";
    private static final String MYSQL_MEDIUMBLOB = "mediumblob";
    private static final String MYSQL_MEDIUMTEXT = "mediumtext";
    private static final String MYSQL_LONGBLOB = "longblob";
    private static final String MYSQL_LONGTEXT = "longtext";



    @Override
    protected Map<String, String> setTypeData() {
        typeMap = new HashMap<String, String>();
        typeMap.put(MYSQL_TINYINT,JAVA_SHORT);
        typeMap.put(MYSQL_SMALLINT,JAVA_SHORT);
        typeMap.put(MYSQL_MEDIUMINT,JAVA_INTEGER);
        typeMap.put(MYSQL_INT,JAVA_INTEGER);
        typeMap.put(MYSQL_BIGINT,JAVA_LONG);
        typeMap.put(MYSQL_FLOAT,JAVA_FLOAT);
        typeMap.put(MYSQL_DOUBLE,JAVA_DOUBLE);
        typeMap.put(MYSQL_DECIMAL,JAVA_DECIMAL);
        typeMap.put(MYSQL_DATE,JAVA_DATE);
        typeMap.put(MYSQL_TIME,JAVA_STRING);
        typeMap.put(MYSQL_YEAR,JAVA_STRING);
        typeMap.put(MYSQL_DATETIME,JAVA_DATE);
        typeMap.put(MYSQL_TIMESTAMP,JAVA_DATE);
        typeMap.put(MYSQL_CHAR,JAVA_CHAR);
        typeMap.put(MYSQL_VARCHAR ,JAVA_STRING);
        typeMap.put(MYSQL_TINYBLOB ,JAVA_BYTE);
        typeMap.put(MYSQL_TINYTEXT ,JAVA_STRING);
        typeMap.put(MYSQL_BLOB,JAVA_BYTE);
        typeMap.put(MYSQL_TEXT,JAVA_STRING);
        typeMap.put(MYSQL_MEDIUMBLOB ,JAVA_BYTE);
        typeMap.put(MYSQL_MEDIUMTEXT ,JAVA_STRING);
        typeMap.put(MYSQL_LONGBLOB,JAVA_BYTE);
        typeMap.put(MYSQL_LONGTEXT,JAVA_STRING);
        super.setTypeMap(typeMap);
        return typeMap;
    }
}
